#ifndef CV_INCLUDED
#define CV_INCLUDED

#include <opencv2/opencv.hpp>
#include <opencv2/imgproc/types_c.h>
#include <string>

using namespace cv;
using namespace std;

#define AMMOR_HEIGHT 100

typedef struct {
	double F;
	double pix_len;
	double loc_vert_len_mm;
	double loc_hori_len_mm;
}Camera_INFO;

typedef Mat AccMat;

extern string program_root_path;

extern Mat element3X3, element5X5, element7X7, element9X9, element11X11;

constexpr int FEATURE_COLS = 2;
constexpr int FEATURE_ROWS = 3;
constexpr double FEATURE_SIZE = (double)FEATURE_COLS * (double)FEATURE_ROWS;

template <class TpMat = Mat>
void show_image(const char* winname, TpMat& image, int win_width){
	TpMat display;
	resize(image, display, Size(win_width, image.rows * win_width / image.cols));
	imshow(winname, display);
	return;
};

bool Pre_proc(AccMat& input_frame, AccMat& output_bin);

void arrange_rrect_points(Point2f* rrect_src, Point2f* rrect_dst);

bool get_item_feature(Mat& Input_image, Mat& out_feature);

double find_ammor_to_arm_dri_vec(RotatedRect& ammor_rrect, Point2f& arm_center, Point2f& dri_vec);

double get_and_match(Mat& input_frame, Mat& input_template, Mat& input_template_feature, RotatedRect& getted_ammor, RotatedRect& getted_leap, Point2f &center_pt, double precision);

//This coordination system is at vision center.
double position_proc(Point2f& io_point_angle, RotatedRect& ammor_rrect, Camera_INFO& camera_info, double uphead_angle = 0.0);

bool get_item_feature_AccMat(AccMat& Input_image, Mat& out_feature, vector<Point> &contour) ;

double get_and_match_AccMat(AccMat& input_frame, AccMat& input_template, Mat& input_template_feature, RotatedRect& getted_ammor, RotatedRect& getted_leap, Point2f &center_pt, double precision) ;

#endif //CV_INCLUDED